// JavaScript Document
 class Carousel {
            constructor(container) {
                this.container = container;
                this.items = container.querySelectorAll('.carousel-item');
                this.indicators = container.querySelectorAll('.carousel-indicator');
                this.currentIndex = 0;
                this.autoPlayInterval = null;
                
                this.initEvents();
                this.startAutoPlay();
            }
 
            initEvents() {
                // 左右箭头点击
                this.container.querySelector('.prev').addEventListener('click', () => this.prev());
                this.container.querySelector('.next').addEventListener('click', () => this.next());
 
                // 指示器点击
                this.indicators.forEach((indicator, index) => {
                    indicator.addEventListener('click', () => this.goTo(index));
                });
 
                // 鼠标悬停暂停
                this.container.addEventListener('mouseenter', () => this.stopAutoPlay());
                this.container.addEventListener('mouseleave', () => this.startAutoPlay());
            }
 
            update() {
                // 更新轮播项
                this.items.forEach((item, index) => {
                    item.classList.toggle('active', index === this.currentIndex);
                });
 
                // 更新指示器
                this.indicators.forEach((indicator, index) => {
                    indicator.classList.toggle('active', index === this.currentIndex);
                });
            }
 
            next() {
                this.currentIndex = (this.currentIndex + 1) % this.items.length;
                this.update();
            }
 
            prev() {
                this.currentIndex = (this.currentIndex - 1 + this.items.length) % this.items.length;
                this.update();
            }
 
            goTo(index) {
                this.currentIndex = index;
                this.update();
            }
 
            startAutoPlay() {
                this.stopAutoPlay();
                this.autoPlayInterval = setInterval(() => this.next(), 3000);
            }
 
            stopAutoPlay() {
                if (this.autoPlayInterval) {
                    clearInterval(this.autoPlayInterval);
                    this.autoPlayInterval = null;
                }
            }
        }
 
        // 初始化轮播
        const carousel = new Carousel(document.querySelector('.carousel'));